package com.ztjava.common.controller;

import com.jfinal.aop.Before;
import com.jfinal.aop.Duang;
import com.jfinal.kit.Ret;
import com.ztjava.common.service.PushService;
import com.ztjava.common.validator.PushValidator;
import com.ztjava.core.Constant;
import com.ztjava.core.base.BaseController;
import com.ztjava.core.bean.sub.PushBean;
import com.ztjava.core.utiliy.RequestUtil;

public class PushBaseController extends BaseController{
	private static PushService pushService = Duang.duang(PushService.class);
	/***
	 * 验证码消息推送
	 */
	@Before(PushValidator.class)
	public void captcha(){
		String to = getPara("to");
		String captcha = pushService.insertCaptcha(Constant.P_MEMBER,  
				getPara("auth_type"),  getPara("to"), 
				RequestUtil.getIp(getRequest()));
		PushBean pushBean = new PushBean("CAPTCHA","COMMON", "SYSTEM", to, 0, new String[]{"captcha",captcha});
		Ret result =  pushService.push(pushBean);
		renderRet(result);
	}
}
